#!/sbin/sh
#
# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
# Licensed under the Academic Free License version 2.1
#
# ident	"%Z%%M%	%I%	%E% SMI"

. /lib/svc/share/smf_include.sh

case "$1" in
'start')
        if smf_is_nonglobalzone; then
                /usr/sbin/svcadm disable $SMF_FMRI
                echo "$SMF_FMRI is not supported in a local zone"
                sleep 5 &
                exit $SMF_EXIT_OK
        fi

	[ ! -x /usr/lib/hal/hald ] && exit $SMF_EXIT_ERR_CONFIG

	[ ! -d /var/run/hald ] && /usr/bin/mkdir -m 755 /var/run/hald
	[ ! -d /media ] && /usr/bin/mkdir -m 755 /media

	/usr/lib/hal/hald --daemon=yes
	err=$?
	if [ $err -ne 0 ]; then
		echo "hal failed to start: error $err"
		exit $SMF_EXIT_ERR_FATAL
	fi
	;;
*)
        echo "Usage: $0 { start }"
	exit $SMF_EXIT_ERR_FATAL 
        ;;
esac

exit $SMF_EXIT_OK
